home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume20 / psroff / part05 < prev    next >
Encoding:
Internet Message Format  |  1989-10-17  |  37.5 KB

  1. Subject:  v20i037:  Troff upgrade for PostScript, DiTroff compatibility, Part05/06
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Chris Lewis <eci386!clewis@uunet.uu.net>
  7. Posting-number: Volume 20, Issue 37
  8. Archive-name: psroff/part05
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of archive 5 (of 6)."
  17. # Contents:  dt.c ps.c
  18. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  19. if test -f 'dt.c' -a "${1}" != "-c" ; then 
  20.   echo shar: Will not clobber existing file \"'dt.c'\"
  21. else
  22. echo shar: Extracting \"'dt.c'\" \(16363 characters\)
  23. sed "s/^X//" >'dt.c' <<'END_OF_FILE'
  24. X/*    Copyright 1985, 1986, 1987, 1988 Chris Lewis
  25. X        All Rights Reserved
  26. X
  27. X    Permission to copy and further distribute is freely given provided 
  28. X    this copyright notice remains intact and that this software is not 
  29. X    sold for profit.
  30. X
  31. X    Project:    Generic Troff drivers
  32. X    Module:        dt.c
  33. X    Author:     Chris Lewis
  34. X    Specs:        Ditroff driver
  35. X */
  36. X
  37. X#include "defs.h"
  38. X
  39. X#ifdef    DT
  40. X#include "dt.h"
  41. X
  42. Xint currentPage = 0;
  43. X
  44. X#ifndef    SVR3
  45. X#ifndef    lint
  46. Xstatic char SCCSid[] = "@(#)dt.c: 1.5 Copyright 89/07/04 16:59:46 Chris Lewis";
  47. X#endif
  48. X#else
  49. X#ident  "@(#)dt.c: 1.5 Copyright 89/07/04 16:59:46 Chris Lewis" /*(SVR3)*/
  50. X#endif
  51. X
  52. X#define    MAXFONT    50
  53. X
  54. X#define    USED    01
  55. X
  56. Xstruct dtFts {
  57. X    char *troffName;
  58. X    char *ascName;
  59. X    int     flags;
  60. X} dtFts[MAXFONT+1];
  61. X
  62. Xstruct dtFts *t2dtf[8];
  63. X
  64. Xstruct troff2befont dtStdFont[108] = {
  65. X
  66. X/*          +-------------------------------- Troff character number
  67. X        |
  68. X            |    +--------------------------- U: standard fonts
  69. X            |    |                            S: symbol font
  70. X            |    |                            D: draw macro
  71. X            |    |                            n: new font
  72. X            |    |
  73. X            |    |  +------------------------ X-shift (scaled by point)
  74. X            |    |  |                         Note: positive is right.
  75. X            |    |  |
  76. X            |    |  |  +--------------------- Y-shift (scaled by point)
  77. X            |    |  |  |                      Note: positive is up.
  78. X            |    |  |  |
  79. X            |    |  |  |  +------------------ Point scale factor
  80. X            |    |  |  |  |
  81. X            |    |  |  |  |   +-------------- Sequence
  82. X            |    |  |  |  |   |
  83. X            |    |  |  |  |   |               Printable sequence title
  84. X            |    |  |  |  |   |                 |
  85. X            |    |  |  |  |   |                 |
  86. X            v    v  v  v  v   v                 v                    */
  87. X    /*  1*/    {U, 0, 0, 1, "h",        "h"},
  88. X    /*  2*/    {U, 0, 0, 1, "t",        "t"},
  89. X    /*  3*/    {U, 0, 0, 1, "n",        "n"},
  90. X    /*  4*/    {U, 0, 0, 1, "m",        "m"},
  91. X    /*  5*/    {U, 0, 0, 1, "l",        "l"},
  92. X    /*  6*/    {U, 0, 0, 1, "i",        "i"},
  93. X    /*  7*/    {U, 0, 0, 1, "z",        "z"},
  94. X    /*  8*/    {U, 0, 0, 1, "s",        "s"},
  95. X    /*  9*/    {U, 0, 0, 1, "d",        "d"},
  96. X    /* 10*/    {U, 0, 0, 1, "b",        "b"},
  97. X    /* 11*/    {U, 0, 0, 1, "x",        "x"},
  98. X    /* 12*/    {U, 0, 0, 1, "f",        "f"},
  99. X    /* 13*/    {U, 0, 0, 1, "j",        "j"},
  100. X    /* 14*/    {U, 0, 0, 1, "u",        "u"},
  101. X    /* 15*/    {U, 0, 0, 1, "k",        "k"},
  102. X    /* 16*/    {U, 0, 0, 1, NOCODE,        "unassigned"},
  103. X    /* 17*/    {U, 0, 0, 1, "p",        "p"},
  104. X    /* 18*/    {U, 0, 0, 1, "em",        "3/4 em"},
  105. X    /* 19*/    {U, 0, 0, 1, ";",        ";"},
  106. X    /* 20*/    {U, 0, 0, 1, NOCODE,        "unassigned"},
  107. X    /* 21*/    {U, 0, 0, 1, "a",        "a"},
  108. X    /* 22*/    {U, 0, 0, 1, "ru",        "horizontal rule"},
  109. X    /* 23*/    {U, 0, 0, 1, "c",        "c"},
  110. X    /* 24*/    {U, 0, 0, 1, "`",        "` open"},
  111. X    /* 25*/    {U, 0, 0, 1, "e",        "e"},
  112. X    /* 26*/    {U, 0, 0, 1, "'",        "' close"},
  113. X    /* 27*/    {U, 0, 0, 1, "o",        "o"},
  114. X    /* 28*/    {U, 0, 0, 1, "14",        "1/4"},
  115. X    /* 29*/    {U, 0, 0, 1, "r",        "r"},
  116. X    /* 30*/    {U, 0, 0, 1, "12",        "1/2"},
  117. X    /* 31*/    {U, 0, 0, 1, "v",        "v"},
  118. X    /* 32*/    {U, 0, 0, 1, "hy",        "- hyphen"},
  119. X    /* 33*/    {U, 0, 0, 1, "w",        "w"},
  120. X    /* 34*/    {U, 0, 0, 1, "q",        "q"},
  121. X    /* 35*/    {U, 0, 0, 1, "/",        "/"},
  122. X    /* 36*/    {U, 0, 0, 1, ".",        "."},
  123. X    /* 37*/    {U, 0, 0, 1, "g",        "g"},
  124. X    /* 38*/    {U, 0, 0, 1, "34",        "3/4"},
  125. X    /* 39*/    {U, 0, 0, 1, ",",        ","},
  126. X    /* 40*/    {U, 0, 0, 1, "&",        "&"},
  127. X    /* 41*/    {U, 0, 0, 1, "y",        "y"},
  128. X    /* 42*/    {U, 0, 0, 1, NOCODE,        "unassigned"},
  129. X    /* 43*/    {U, 0, 0, 1, "%",        "%"},
  130. X    /* 44*/    {U, 0, 0, 1, NOCODE,        "unassigned"},
  131. X    /* 45*/    {U, 0, 0, 1, "Q",        "Q"},
  132. X    /* 46*/    {U, 0, 0, 1, "T",        "T"},
  133. X    /* 47*/    {U, 0, 0, 1, "O",        "O"},
  134. X    /* 48*/    {U, 0, 0, 1, "H",        "H"},
  135. X    /* 49*/    {U, 0, 0, 1, "N",        "N"},
  136. X    /* 50*/    {U, 0, 0, 1, "M",        "M"},
  137. X    /* 51*/    {U, 0, 0, 1, "L",        "L"},
  138. X    /* 52*/    {U, 0, 0, 1, "R",        "R"},
  139. X    /* 53*/    {U, 0, 0, 1, "G",        "G"},
  140. X    /* 54*/    {U, 0, 0, 1, "I",        "I"},
  141. X    /* 55*/    {U, 0, 0, 1, "P",        "P"},
  142. X    /* 56*/    {U, 0, 0, 1, "C",        "C"},
  143. X    /* 57*/    {U, 0, 0, 1, "V",        "V"},
  144. X    /* 58*/    {U, 0, 0, 1, "E",        "E"},
  145. X    /* 59*/    {U, 0, 0, 1, "Z",        "Z"},
  146. X    /* 60*/    {U, 0, 0, 1, "D",        "D"},
  147. X    /* 61*/    {U, 0, 0, 1, "B",        "B"},
  148. X    /* 62*/    {U, 0, 0, 1, "S",        "S"},
  149. X    /* 63*/    {U, 0, 0, 1, "Y",        "Y"},
  150. X    /*from here on are actually code 1-45, upper half of font */
  151. X    /* 64*/    {U, 0, 0, 1, "F",        "F"},
  152. X    /* 65*/    {U, 0, 0, 1, "X",        "X"},
  153. X    /* 66*/    {U, 0, 0, 1, "A",        "A"},
  154. X    /* 67*/    {U, 0, 0, 1, "W",        "W"},
  155. X    /* 68*/    {U, 0, 0, 1, "J",        "J"},
  156. X    /* 69*/    {U, 0, 0, 1, "U",        "U"},
  157. X    /* 70*/    {U, 0, 0, 1, "K",        "K"},
  158. X    /* 71*/    {U, 0, 0, 1, "0",        "0"},
  159. X    /* 72*/    {U, 0, 0, 1, "1",        "1"},
  160. X    /* 73*/    {U, 0, 0, 1, "2",        "2"},
  161. X    /* 74*/    {U, 0, 0, 1, "3",        "3"},
  162. X    /* 75*/    {U, 0, 0, 1, "4",        "4"},
  163. X    /* 76*/    {U, 0, 0, 1, "5",        "5"},
  164. X    /* 77*/    {U, 0, 0, 1, "6",        "6"},
  165. X    /* 78*/    {U, 0, 0, 1, "7",        "7"},
  166. X    /* 79*/    {U, 0, 0, 1, "8",        "8"},
  167. X    /* 80*/    {U, 0, 0, 1, "9",        "9"},
  168. X    /* 81*/    {U, 0, 0, 1, "*",        "*"},
  169. X    /* 82*/    {U, 0, 0, 1, "-",        "minus"},
  170. X    /* 83*/    {U, 0, 0, 1, "fi",        "fi"},
  171. X    /* 84*/    {U, 0, 0, 1, "fl",        "fl"},
  172. X    /* 85*/    {U, 0, 0, 1, "ff",        "ff"},
  173. X    /* 86*/    {U, 0, 0, 1, "ct",        "cent sign"},
  174. X    /* 87*/    {U, 0, 0, 1, "Fl",        "ffl"},
  175. X    /* 88*/    {U, 0, 0, 1, "Fi",        "ffi"},
  176. X    /* 89*/    {U, 0, 0, 1, "(",        "("},
  177. X    /* 90*/    {U, 0, 0, 1, ")",        ")"},
  178. X    /* 91*/    {U, 0, 0, 1, "[",        "["},
  179. X    /* 92*/    {U, 0, 0, 1, "]",        "]"},
  180. X    /* 93*/    {U, 0, 0, 1, "de",        "degree"},
  181. X    /* 94*/    {U, 0, 0, 1, "dg",        "dagger"},
  182. X    /* 95*/    {U, 0, 0, 1, "=",        "="},
  183. X    /* 96*/    {U, 0, 0, 1, "rg",        "registered"},
  184. X    /* 97*/    {U, 0, 0, 1, ":",        ":"},
  185. X    /* 98*/    {U, 0, 0, 1, "+",        "+"},
  186. X    /* 99*/    {U, 0, 0, 1, NOCODE,        "unassigned"},
  187. X    /*100*/    {U, 0, 0, 1, "!",        "!"},
  188. X    /*101*/    {U, 0, 0, 1, "bu",        "bullet"},
  189. X    /*102*/    {U, 0, 0, 1, "?",        "?"},
  190. X    /*103*/    {U, 0, 0, 1, "fm",        "foot mark (minute)"},
  191. X    /*104*/    {U, 0, 0, 1, "|",        "|"},
  192. X    /*105*/    {U, 0, 0, 1, NOCODE,        "unassigned"},
  193. X    /*106*/    {U, 0, 0, 1, "co",        "copyright"},
  194. X    /*107*/    {U, 0, 0, 1, "sq",        "square"},
  195. X    /*108*/    {U, 0, 0, 1, "$",        "$"}
  196. X};
  197. X
  198. Xstruct troff2befont dtSymFont[] = {
  199. X/*          +-------------------------------- Troff character number
  200. X        |
  201. X            |    +--------------------------- U: standard fonts
  202. X            |    |                            S: symbol font
  203. X            |    |                            D: draw macro
  204. X            |    |
  205. X            |    |  +------------------------ X-shift (scaled by point)
  206. X            |    |  |                         Note: positive is right.
  207. X            |    |  |
  208. X            |    |  |  +--------------------- Y-shift (scaled by point)
  209. X            |    |  |  |                      Note: positive is up.
  210. X            |    |  |  |
  211. X            |    |  |  |  +------------------ Point scale factor
  212. X            |    |  |  |  |
  213. X            |    |  |  |  |   +-------------- Sequence
  214. X            |    |  |  |  |   |
  215. X            |    |  |  |  |   |               Printable sequence title
  216. X            |    |  |  |  |   |                 |
  217. X            |    |  |  |  |   |                 |
  218. X            v    v  v  v  v   v                 v                    */
  219. X    /*  1*/    {S, 0, 0, 1, "*q",        "psi"},
  220. X    /*  2*/    {S, 0, 0, 1, "*h",        "theta"},
  221. X    /*  3*/    {S, 0, 0, 1, "*n",        "nu"},
  222. X    /*  4*/    {S, 0, 0, 1, "*m",        "mu"},
  223. X    /*  5*/    {S, 0, 0, 1, "*l",        "lambda"},
  224. X    /*  6*/    {S, 0, 0, 1, "*i",        "iota"},
  225. X    /*  7*/    {S, 0, 0, 1, "*z",        "zeta"},
  226. X    /*  8*/    {S, 0, 0, 1, "*s",        "sigma"},
  227. X    /*  9*/    {S, 0, 0, 1, "*d",        "delta"},
  228. X    /* 10*/    {S, 0, 0, 1, "*b",        "beta"},
  229. X    /* 11*/    {S, 0, 0, 1, "*c",        "xi"},
  230. X    /* 12*/    {S, 0, 0, 1, "*y",        "eta"},
  231. X    /* 13*/    {S, 0, 0, 1, "*f",        "phi"},
  232. X    /* 14*/    {S, 0, 0, 1, "*u",        "upsilon"},
  233. X    /* 15*/    {S, 0, 0, 1, "*k",        "kappa"},
  234. X    /* 16*/    {S, 0, 0, 1, NOCODE,        "unassigned"},
  235. X    /* 17*/    {S, 0, 0, 1, "*p",        "pi"},
  236. X    /* 18*/    {S, 0, 0, 1, "@",        "@"},
  237. X    /* 19*/    {S, 0, 0, 1, "da",        "down arrow"},
  238. X    /* 20*/    {S, 0, 0, 1, NOCODE,        "unassigned"},
  239. X    /* 21*/    {S, 0, 0, 1, "*a",        "alpha"},
  240. X    /* 22*/    {S, 0, 0, 1, "or",        "or (was star)"},
  241. X    /* 23*/    {S, 0, 0, 1, "*x",        "chi"},
  242. X    /* 24*/    {U, 0, 0, 1, "\"",        "double quote"},
  243. X    /* 25*/    {S, 0, 0, 1, "*e",        "epsilon"},
  244. X    /* 26*/    {S, 0, 0, 1, "eq",        "equation equal"},
  245. X    /* 27*/    {S, 0, 0, 1, "*o",        "omicron"},
  246. X    /* 28*/    {S, 0, 0, 1, "<-",        "left arrow"},
  247. X    /* 29*/    {S, 0, 0, 1, "*r",        "rho"},
  248. X    /* 30*/    {S, 0, 0, 1, "ua",        "up arrow"},
  249. X    /* 31*/    {S, 0, 0, 1, "*t",        "tau"},
  250. X    /* 32*/    {S, 0, 0, 1, "ul",        "underline"},
  251. X    /* 33*/    {U, 0, 0, 1, "\\",        "back slash"},
  252. X    /* 34*/    {S, 0, 0, 1, "*Q",        "Psi"},
  253. X    /* 35*/    {S, 0, 0, 1, "?",        "bell system sign"},
  254. X    /* 36*/    {S, 0, 0, 1, "if",        "infinity"},
  255. X    /* 37*/    {S, 0, 0, 1, "*g",        "gamma"},
  256. X    /* 38*/    {S, 0, 0, 1, "ip",        "improper superset"},
  257. X    /* 39*/    {S, 0, 0, 1, "pt",        "proportional to"},
  258. X    /* 40*/    {S, 0, 0, 1, "rh",        "right hand"},
  259. X    /* 41*/    {S, 0, 0, 1, "*w",        "omega"},
  260. X    /* 42*/    {S, 0, 0, 1, NOCODE,        "unassigned"},
  261. X    /* 43*/    {S, 0, 0, 1, "gr",        "gradient"},
  262. X    /* 44*/    {S, 0, 0, 1, NOCODE,        "unassigned"},
  263. X    /* 45*/    {S, 0, 0, 1, "*F",        "Phi"},
  264. X    /* 46*/    {S, 0, 0, 1, "*H",        "Theta"},
  265. X    /* 47*/    {S, 0, 0, 1, "*W",        "Omega"},
  266. X    /* 48*/    {S, 0, 0, 1, "cu",        "union"},
  267. X    /* 49*/    {S, 0, 0, 1, "rn",        "root en"},
  268. X    /* 50*/    {S, 0, 0, 1, "ts",        "terminal sigma (was root em)"},
  269. X    /* 51*/    {S, 0, 0, 1, "*L",        "Lambda"},
  270. X    /* 52*/    {S, 0, 0, 1, "mi",        "equation minus"},
  271. X    /* 53*/    {S, 0, 0, 1, "*G",        "Gamma"},
  272. X    /* 54*/    {S, 0, 0, 1, "is",        "integral sign"},
  273. X    /* 55*/    {S, 0, 0, 1, "*P",        "Pi"},
  274. X    /* 56*/    {S, 0, 0, 1, "sb",        "subset of"},
  275. X    /* 57*/    {S, 0, 0, 1, "sp",        "superset of"},
  276. X    /* 58*/    {S, 0, 0, 1, "ap",        "approximates"},
  277. X    /* 59*/    {S, 0, 0, 1, "pd",        "partial derivative"},
  278. X    /* 60*/    {S, 0, 0, 1, "*D",        "Delta"},
  279. X    /* 61*/    {S, 0, 0, 1, "sr",        "square root"},
  280. X    /* 62*/    {S, 0, 0, 1, "*S",        "Sigma"},
  281. X    /* 63*/    {S, 0, 0, 1, "~=",        "approx ="},
  282. X    /* 64*/    {S, 0, 0, 1, ">",        ">"},
  283. X    /* 65*/    {S, 0, 0, 1, "*C",        "Xi"},
  284. X    /* 66*/    {S, 0, 0, 1, "<",        "<"},
  285. X    /* 67*/    {S, 0, 0, 1, "/",        "slash"},
  286. X    /* 68*/    {S, 0, 0, 1, "ca",        "intersect"},
  287. X    /* 69*/    {S, 0, 0, 1, "*U",        "Upsilon"},
  288. X    /* 70*/    {S, 0, 0, 1, "no",        "logical not"},
  289. X    /* 71*/    {S, 0, 0, 1, "rc",        "right ceiling"},
  290. X    /* 72*/    {S, 0, 0, 1, "lt",        "left top brace"},
  291. X    /* 73*/    {S, 0, 0, 1, "bv",        "bold vertical"},
  292. X    /* 74*/    {S, 0, 0, 1, "lk",        "left ctr brace"},
  293. X    /* 75*/    {S, 0, 0, 1, "lb",        "left bot brace"},
  294. X    /* 76*/    {S, 0, 0, 1, "rt",        "right top brace"},
  295. X    /* 77*/    {S, 0, 0, 1, "rk",        "right ctr brace"},
  296. X    /* 78*/    {S, 0, 0, 1, "rb",        "right bot brace"},
  297. X    /* 79*/    {S, 0, 0, 1, "rf",        "right floor"},
  298. X    /* 80*/    {S, 0, 0, 1, "lf",        "left floor"},
  299. X    /* 81*/    {S, 0, 0, 1, "lc",        "left ceiling"},
  300. X    /* 82*/    {S, 0, 0, 1, "mu",        "multiply"},
  301. X    /* 83*/    {S, 0, 0, 1, "di",        "divide"},
  302. X    /* 84*/    {S, 0, 0, 1, "+-",        "plus-minus"},
  303. X    /* 85*/    {S, 0, 0, 1, "<=",        "<="},
  304. X    /* 86*/    {S, 0, 0, 1, ">=",        ">="},
  305. X    /* 87*/    {S, 0, 0, 1, "==",        "identically equal"},
  306. X    /* 88*/    {S, 0, 0, 1, "!=",        "not equal"},
  307. X    /* 89*/    {S, 0, 0, 1, "{",        "{"},
  308. X    /* 90*/    {S, 0, 0, 1, "}",        "}"},
  309. X    /* 91*/    {U, 0, 0, 1, "aa",        "acute accent"},
  310. X    /* 92*/    {U, 0, 0, 1, "ga",        "grave accent"},
  311. X    /* 93*/    {S, 0, 0, 1, "^",        "^"},
  312. X    /* 94*/    {S, 0, 0, 1, "#",        "#"},
  313. X    /* 95*/    {S, 0, 0, 1, "lh",        "left hand"},
  314. X    /* 96*/    {S, 0, 0, 1, "mo",        "member of"},
  315. X    /* 97*/    {U, 0, 0, 1, "~",        "~"},
  316. X    /* 98*/    {S, 0, 0, 1, "es",        "empty set"},
  317. X    /* 99*/    {S, 0, 0, 1, NOCODE,        "unassigned"},
  318. X    /*100*/    {U, 0, 0, 1, "dd",        "dbl dagger"},
  319. X    /*101*/    {S, 0, 0, 1, "br",        "box rule (was parallel sign)"},
  320. X    /*102*/    {S, 0, 0, 1, "**",        "math * "},
  321. X    /*103*/    {S, 0, 0, 1, "ib",        "improper subset"},
  322. X    /*104*/    {S, 0, 0, 1, "ci",        "circle"},
  323. X    /*105*/    {S, 0, 0, 1, NOCODE,        "unassigned"},
  324. X    /*106*/    {S, 0, 0, 1, "pl",        "equation plus"},
  325. X    /*107*/    {S, 0, 0, 1, "->",        "right arrow"},
  326. X    /*108*/    {U, 0, 0, 1, "sc",        "section"}
  327. X};
  328. X
  329. XdtPage() {
  330. X    pagePending = 1;
  331. X}
  332. X
  333. Xstatic
  334. XdoPageStart(e) {
  335. X    currentPage++;
  336. X    pagePending = 0;
  337. X    printf("p%d\n", currentPage);
  338. X}
  339. X
  340. Xstatic int lastFont = (-1), lastPoints = (-1);
  341. X
  342. XdtSetFont(font, points)
  343. Xint font, points; {
  344. X    if (lastPoints != points || font != lastFont) {
  345. X    if (!(dtFts[font].flags)&USED)
  346. X        printf("x font %d %s\n", font+1, dtFts[font].troffName);
  347. X    dtFts[font].flags |= USED;
  348. X    printf("f%d\n", font+1);
  349. X    printf("s%d\n", points);
  350. X    lastPoints = points;
  351. X    lastFont = font;
  352. X    }
  353. X}
  354. X
  355. XdtChar(x, y, font, points, troffChar) 
  356. Xint x, y, font, points, troffChar; {
  357. X    static double lasty = (-1);
  358. X    register double nx = TROFF2DTX(x), ny = TROFF2DTY(y);
  359. X    register struct troff2befont *rp;
  360. X    register char *sequence = "a";
  361. X    if (pagePending) {
  362. X        lasty = lastFont = lastPoints = (-1);
  363. X        doPageStart();
  364. X    }
  365. X
  366. X    DEBUGPRINTF("x,y=%d,%d; font=%d, points=%d, tc=%d\n",
  367. X        x, y, font, points, troffChar);
  368. X
  369. X    if (font == 3) {
  370. X        rp = &be->besymfont[troffChar];
  371. X    } else {
  372. X        rp = &be->bestdfont[troffChar];
  373. X    }
  374. X
  375. X    switch(rp->t2b_font) {
  376. X        /* Only fonts with "U" are subject to font translation */
  377. X        case U: 
  378. X        if (font == 3)
  379. X            font = 0;    /* Special chars are Courier */
  380. X        else {
  381. X            DEBUGPRINTF("dtSetChar %d->%s (%s)\n", font, 
  382. X            t2dtf[font]->troffName,
  383. X            t2dtf[font]->ascName);
  384. X            font = t2dtf[font] - dtFts;
  385. X        }
  386. X        break;
  387. X        case S: 
  388. X        font = 3;
  389. X        break;
  390. X        case D:
  391. X        break;
  392. X        default:
  393. X        /* Typically used when the main fonts don't have the
  394. X           character desired.  Eg: right-hand is in the
  395. X           ZapfDingbats font */
  396. X        font = rp->t2b_font;
  397. X        break;
  398. X    }
  399. X
  400. X    sequence = rp->t2b_charseq;
  401. X
  402. X    if (!sequence) {
  403. X        fprintf(stderr, "No coding for %d\n", troffChar);
  404. X        return;
  405. X    }
  406. X
  407. X    /*    We're committed now */
  408. X
  409. X    points *= rp->t2b_scale;
  410. X    nx += points * rp->t2b_xc;
  411. X    ny += points * rp->t2b_yc;
  412. X    dtSetFont(font, points);
  413. X#ifdef    NOTYET
  414. X    if (rp->t2b_font == D)
  415. X        printf("H%d\nV%d\nc%s\n", (int) nx, (int) ny, sequence);
  416. X    else {
  417. X#endif
  418. X        printf("H%d\n", (int) nx);
  419. X        if (lasty != ny) {
  420. X        printf("V%d\n", (int) ny);
  421. X        lasty = ny;
  422. X        }
  423. X        if (sequence[1])
  424. X        printf("C%s\n", sequence);
  425. X        else
  426. X        printf("c%s\n", sequence);
  427. X#ifdef    NOTYET
  428. X    }
  429. X#endif
  430. X}
  431. X
  432. XdtProlog() {
  433. X    extern char *getlogin(), *ctime();
  434. X    extern char *strchr();
  435. X    extern char nodename[];
  436. X    extern char *device;
  437. X    char buf2[512];
  438. X    char buffer[512];
  439. X    FILE *library;
  440. X    int c;
  441. X    long curtime;
  442. X
  443. X    currentPage = 0;
  444. X    pagePending = 1;
  445. X
  446. X    for (c = 0; c < 8; c++)
  447. X    t2dtf[c] = &dtFts[c];
  448. X
  449. X    sprintf(buf2, "%s.%s", DTFONTS, be->bename);
  450. X
  451. X    if ((library = fopen(buf2, "r")) == NULL) {
  452. X    sprintf(buffer, "%s/%s", LIBDIR, buf2);
  453. X    if ((library = fopen(buffer, "r")) == NULL) {
  454. X        fprintf(stderr, "Cannot open PostScript font definitions %s\n",
  455. X        buffer);
  456. X        exit(1);
  457. X    }
  458. X    }
  459. X
  460. X    loadfontdefs(library);
  461. X    fclose(library);
  462. X
  463. X    time(&curtime);
  464. X    strcpy(buffer, ctime(&curtime));
  465. X    *strchr(buffer, '\n') = '\0';
  466. X
  467. X    getnodename();
  468. X
  469. X    printf("#Title: (stdin)\n");
  470. X    printf("#Creator: %s %s %s\n", getlogin(), progname, T2VERSION);
  471. X    printf("#CreationDate: %s\n", buffer);
  472. X    printf("#For: %s\n", getlogin());
  473. X    printf("#Pages: (atend)\n");
  474. X    printf("#DocumentFonts: (atend)\n");
  475. X    printf("#EndComments\n");
  476. X    printf("x T %s\n", device);
  477. X    printf("x res %d %d %d\n", DTRESOLUTION, 1, 1);
  478. X    printf("x init\n");
  479. X
  480. X}
  481. X
  482. XdtEpilog() {
  483. X    printf("x trailer\n");
  484. X    printf("x stop\n");
  485. X}
  486. X
  487. XdtFontSel(from, to)
  488. Xchar from, *to; {
  489. X#ifdef    DEBUG
  490. X    register int i;
  491. X    register struct dtFts *p;
  492. X#endif
  493. X    DEBUGPRINTF("dtFontSel: %c -> %s\n", from, to);
  494. X    if (from < '1' || from > '8') {
  495. X    fprintf(stderr, "Bad arguments to dtFontSel: %c %s\n", from, to);
  496. X    return;
  497. X    }
  498. X
  499. X    for (p = dtFts; p->troffName; p++)
  500. X    if (strcmp(p->troffName, to) == 0) {
  501. X        t2dtf[from - '1'] = p;
  502. X        break;
  503. X    }
  504. X    if (!p->troffName) {
  505. X    fprintf(stderr, "Could not translate font %c (%s)\n", from, to);
  506. X    }
  507. X#ifdef    DEBUG
  508. X    for (i = 0; i < 8; i++)
  509. X    DEBUGPRINTF("Font %d->%s\n", i+1, t2dtf[i]->ascName);
  510. X#endif
  511. X}
  512. X
  513. X/*struct troff2befont *
  514. XdtGetFontTables(which)
  515. Xint which; {
  516. X    return(which? symbolFont: standardFont);
  517. X}*/
  518. X
  519. Xstatic
  520. Xloadfontdefs(f)
  521. XFILE *f; {
  522. X    struct dtFts *p = dtFts;
  523. X    extern char *malloc();
  524. X    int flags;
  525. X    char rbuf[512], nbuf[512], dtbuf[512];
  526. X    while(fgets(rbuf, sizeof(rbuf), f)) {
  527. X    if (rbuf[0] == '#')
  528. X        continue;
  529. X    switch(sscanf(rbuf, "%s%s", nbuf, dtbuf)) {
  530. X        default:
  531. X        break;
  532. X        case 2:
  533. X        if (nbuf[0] == '#')
  534. X            break;
  535. X        if (p - dtFts >= MAXFONT) {
  536. X            fprintf(stderr, "Too many font definitions in %s\n",
  537. X            be->bename);
  538. X            exit(1);
  539. X        }
  540. X        p->troffName = malloc(strlen(nbuf) + 1);
  541. X        strcpy(p->troffName, nbuf);
  542. X        p->ascName = malloc(strlen(dtbuf) + 1);
  543. X        strcpy(p->ascName, dtbuf);
  544. X        p->flags = 0;
  545. X        p++;
  546. X    }
  547. X    }
  548. X#ifdef    DEBUG
  549. X    for (p = dtFts; p->troffName; p++)
  550. X    DEBUGPRINTF("%s -> %s\n", p->troffName, p->ascName);
  551. X#endif
  552. X}
  553. X#endif /* DT */
  554. END_OF_FILE
  555. if test 16363 -ne `wc -c <'dt.c'`; then
  556.     echo shar: \"'dt.c'\" unpacked with wrong size!
  557. fi
  558. # end of 'dt.c'
  559. fi
  560. if test -f 'ps.c' -a "${1}" != "-c" ; then 
  561.   echo shar: Will not clobber existing file \"'ps.c'\"
  562. else
  563. echo shar: Extracting \"'ps.c'\" \(19066 characters\)
  564. sed "s/^X//" >'ps.c' <<'END_OF_FILE'
  565. X/*    Copyright 1985, 1986, 1987, 1988 Chris Lewis
  566. X        All Rights Reserved
  567. X
  568. X    Permission to copy and further distribute is freely given provided 
  569. X    this copyright notice remains intact and that this software is not 
  570. X    sold for profit.
  571. X
  572. X    Project:    Generic Troff drivers
  573. X    Module:        ps.c
  574. X    Author:     Chris Lewis
  575. X    Specs:        PostScript driver
  576. X */
  577. X
  578. X#include "defs.h"
  579. X
  580. X#ifdef    PS
  581. X#include "ps.h"
  582. X
  583. X#ifndef    SVR3
  584. X#ifndef    lint
  585. Xstatic char SCCSid[] = "@(#)ps.c: 1.24 Copyright 89/08/28 17:11:47 Chris Lewis";
  586. X#endif
  587. X#else
  588. X#ident  "@(#)ps.c: 1.24 Copyright 89/08/28 17:11:47 Chris Lewis" /*(SVR3)*/
  589. X#endif
  590. X
  591. X#define    METRICS
  592. Xstatic charCount;
  593. X
  594. X#ifdef    FORM
  595. Xstatic char Overlay[100] = {""};
  596. X#endif
  597. X
  598. X#ifdef    BIN
  599. Xstatic char Bin = 'D';
  600. X#endif
  601. X
  602. X#define    MAXFONT    50
  603. X
  604. X#define    USED    01
  605. X
  606. Xstruct psFts {
  607. X    char *troffName;
  608. X    char *fontName;
  609. X    int     flags;
  610. X} psFts[MAXFONT+1];
  611. X
  612. Xstruct psFts *t2psf[8];
  613. X
  614. Xstruct troff2befont psStdFont[108] = {
  615. X
  616. X/*          +-------------------------------- Troff character number
  617. X        |
  618. X            |    +--------------------------- U: standard fonts
  619. X            |    |                            S: symbol font
  620. X            |    |                            D: draw macro
  621. X            |    |                            n: new font
  622. X            |    |
  623. X            |    |  +------------------------ X-shift (scaled by point)
  624. X            |    |  |                         Note: positive is right.
  625. X            |    |  |
  626. X            |    |  |  +--------------------- Y-shift (scaled by point)
  627. X            |    |  |  |                      Note: positive is up.
  628. X            |    |  |  |
  629. X            |    |  |  |  +------------------ Point scale factor
  630. X            |    |  |  |  |
  631. X            |    |  |  |  |   +-------------- Sequence
  632. X            |    |  |  |  |   |
  633. X            |    |  |  |  |   |               Printable sequence title
  634. X            |    |  |  |  |   |                 |
  635. X            |    |  |  |  |   |                 |
  636. X            v    v  v  v  v   v                 v                    */
  637. X    /*  1*/    {U, 0, 0, 1, "h",        "h"},
  638. X    /*  2*/    {U, 0, 0, 1, "t",        "t"},
  639. X    /*  3*/    {U, 0, 0, 1, "n",        "n"},
  640. X    /*  4*/    {U, 0, 0, 1, "m",        "m"},
  641. X    /*  5*/    {U, 0, 0, 1, "l",        "l"},
  642. X    /*  6*/    {U, 0, 0, 1, "i",        "i"},
  643. X    /*  7*/    {U, 0, 0, 1, "z",        "z"},
  644. X    /*  8*/    {U, 0, 0, 1, "s",        "s"},
  645. X    /*  9*/    {U, 0, 0, 1, "d",        "d"},
  646. X    /* 10*/    {U, 0, 0, 1, "b",        "b"},
  647. X    /* 11*/    {U, 0, 0, 1, "x",        "x"},
  648. X    /* 12*/    {U, 0, 0, 1, "f",        "f"},
  649. X    /* 13*/    {U, 0, 0, 1, "j",        "j"},
  650. X    /* 14*/    {U, 0, 0, 1, "u",        "u"},
  651. X    /* 15*/    {U, 0, 0, 1, "k",        "k"},
  652. X    /* 16*/    {U, 0, 0, 1, NOCODE,        "unassigned"},
  653. X    /* 17*/    {U, 0, 0, 1, "p",        "p"},
  654. X    /* 18*/    {D, 0, 0, 1, "do34em",        "3/4 em"},
  655. X    /* 19*/    {U, 0, 0, 1, ";",        ";"},
  656. X    /* 20*/    {U, 0, 0, 1, NOCODE,        "unassigned"},
  657. X    /* 21*/    {U, 0, 0, 1, "a",        "a"},
  658. X    /* 22*/    {D, 0, 0, 1, "doru",        "horizontal rule"},
  659. X    /* 23*/    {U, 0, 0, 1, "c",        "c"},
  660. X    /* 24*/    {U, 0, 0, 1, "`",        "` open"},
  661. X    /* 25*/    {U, 0, 0, 1, "e",        "e"},
  662. X    /* 26*/    {U, 0, 0, 1, "'",        "' close"},
  663. X    /* 27*/    {U, 0, 0, 1, "o",        "o"},
  664. X    /* 28*/    {D, 0, 0, 1, "do14",        "1/4"},
  665. X    /* 29*/    {U, 0, 0, 1, "r",        "r"},
  666. X    /* 30*/    {D, 0, 0, 1, "do12",        "1/2"},
  667. X    /* 31*/    {U, 0, 0, 1, "v",        "v"},
  668. X    /* 32*/    {U, 0, 0, 1, "-",        "- hyphen"},
  669. X    /* 33*/    {U, 0, 0, 1, "w",        "w"},
  670. X    /* 34*/    {U, 0, 0, 1, "q",        "q"},
  671. X    /* 35*/    {U, 0, 0, 1, "/",        "/"},
  672. X    /* 36*/    {U, 0, 0, 1, ".",        "."},
  673. X    /* 37*/    {U, 0, 0, 1, "g",        "g"},
  674. X    /* 38*/    {D, 0, 0, 1, "do34",        "3/4"},
  675. X    /* 39*/    {U, 0, 0, 1, ",",        ","},
  676. X    /* 40*/    {U, 0, 0, 1, "&",        "&"},
  677. X    /* 41*/    {U, 0, 0, 1, "y",        "y"},
  678. X    /* 42*/    {U, 0, 0, 1, NOCODE,        "unassigned"},
  679. X    /* 43*/    {U, 0, 0, 1, "\%",        "%"},
  680. X    /* 44*/    {U, 0, 0, 1, NOCODE,        "unassigned"},
  681. X    /* 45*/    {U, 0, 0, 1, "Q",        "Q"},
  682. X    /* 46*/    {U, 0, 0, 1, "T",        "T"},
  683. X    /* 47*/    {U, 0, 0, 1, "O",        "O"},
  684. X    /* 48*/    {U, 0, 0, 1, "H",        "H"},
  685. X    /* 49*/    {U, 0, 0, 1, "N",        "N"},
  686. X    /* 50*/    {U, 0, 0, 1, "M",        "M"},
  687. X    /* 51*/    {U, 0, 0, 1, "L",        "L"},
  688. X    /* 52*/    {U, 0, 0, 1, "R",        "R"},
  689. X    /* 53*/    {U, 0, 0, 1, "G",        "G"},
  690. X    /* 54*/    {U, 0, 0, 1, "I",        "I"},
  691. X    /* 55*/    {U, 0, 0, 1, "P",        "P"},
  692. X    /* 56*/    {U, 0, 0, 1, "C",        "C"},
  693. X    /* 57*/    {U, 0, 0, 1, "V",        "V"},
  694. X    /* 58*/    {U, 0, 0, 1, "E",        "E"},
  695. X    /* 59*/    {U, 0, 0, 1, "Z",        "Z"},
  696. X    /* 60*/    {U, 0, 0, 1, "D",        "D"},
  697. X    /* 61*/    {U, 0, 0, 1, "B",        "B"},
  698. X    /* 62*/    {U, 0, 0, 1, "S",        "S"},
  699. X    /* 63*/    {U, 0, 0, 1, "Y",        "Y"},
  700. X    /*from here on are actually code 1-45, upper half of font */
  701. X    /* 64*/    {U, 0, 0, 1, "F",        "F"},
  702. X    /* 65*/    {U, 0, 0, 1, "X",        "X"},
  703. X    /* 66*/    {U, 0, 0, 1, "A",        "A"},
  704. X    /* 67*/    {U, 0, 0, 1, "W",        "W"},
  705. X    /* 68*/    {U, 0, 0, 1, "J",        "J"},
  706. X    /* 69*/    {U, 0, 0, 1, "U",        "U"},
  707. X    /* 70*/    {U, 0, 0, 1, "K",        "K"},
  708. X    /* 71*/    {U, 0, 0, 1, "0",        "0"},
  709. X    /* 72*/    {U, 0, 0, 1, "1",        "1"},
  710. X    /* 73*/    {U, 0, 0, 1, "2",        "2"},
  711. X    /* 74*/    {U, 0, 0, 1, "3",        "3"},
  712. X    /* 75*/    {U, 0, 0, 1, "4",        "4"},
  713. X    /* 76*/    {U, 0, 0, 1, "5",        "5"},
  714. X    /* 77*/    {U, 0, 0, 1, "6",        "6"},
  715. X    /* 78*/    {U, 0, 0, 1, "7",        "7"},
  716. X    /* 79*/    {U, 0, 0, 1, "8",        "8"},
  717. X    /* 80*/    {U, 0, 0, 1, "9",        "9"},
  718. X    /* 81*/    {U, 0, 0, 1, "*",        "*"},
  719. X    /* 82*/    {S, 0, 0, 1, "\\055",        "minus"},
  720. X    /* 83*/    {U, 0, 0, 1, "\\256",        "fi"},
  721. X    /* 84*/    {U, 0, 0, 1, "\\257",        "fl"},
  722. X    /* 85*/    {D, 0, 0, 1, "doff",        "ff"},
  723. X    /* 86*/    {S, 0, 0, 1, "\\242",        "cent sign"},
  724. X    /* 87*/    {D, 0, 0, 1, "doFl",        "ffl"},
  725. X    /* 88*/    {D, 0, 0, 1, "doFi",        "ffi"},
  726. X    /* 89*/    {U, 0, 0, 1, "\\(",        "("},
  727. X    /* 90*/    {U, 0, 0, 1, "\\)",        ")"},
  728. X    /* 91*/    {U, 0, 0, 1, "[",        "["},
  729. X    /* 92*/    {U, 0, 0, 1, "]",        "]"},
  730. X    /* 93*/    {S, 0, 0, 1, "\\260",        "degree"},
  731. X    /* 94*/    {U, 0, 0, 1, "\\262",        "dagger"},
  732. X    /* 95*/    {U, 0, 0, 1, "=",        "="},
  733. X    /* 96*/    {S, 0, 0, 1, "\\322",        "registered"},
  734. X    /* 97*/    {U, 0, 0, 1, ":",        ":"},
  735. X    /* 98*/    {U, 0, 0, 1, "+",        "+"},
  736. X    /* 99*/    {U, 0, 0, 1, NOCODE,        "unassigned"},
  737. X    /*100*/    {U, 0, 0, 1, "!",        "!"},
  738. X    /*101*/    {U, 0, -.1, 1.5, "\\267",    "bullet"},
  739. X    /*102*/    {U, 0, 0, 1, "?",        "?"},
  740. X    /*103*/    {S, 0, 0, 1, "\\242",        "foot mark (minute)"},
  741. X    /*104*/    {U, -.1, 0, 1, "|",        "|"},
  742. X    /*105*/    {U, 0, 0, 1, NOCODE,        "unassigned"},
  743. X    /*106*/    {S, 0, 0, 1, "\\323",        "copyright"},
  744. X    /*107*/    {D, 0, 0, 1, "dosq",        "square"},
  745. X    /*108*/    {U, 0, 0, 1, "$",        "$"}
  746. X    };
  747. X
  748. X    struct troff2befont psSymFont[] = {
  749. X/*          +-------------------------------- Troff character number
  750. X        |
  751. X            |    +--------------------------- U: standard fonts
  752. X            |    |                            S: symbol font
  753. X            |    |                            D: draw macro
  754. X            |    |                            n: new font
  755. X            |    |
  756. X            |    |  +------------------------ X-shift (scaled by point)
  757. X            |    |  |                         Note: positive is right.
  758. X            |    |  |
  759. X            |    |  |  +--------------------- Y-shift (scaled by point)
  760. X            |    |  |  |                      Note: positive is up.
  761. X            |    |  |  |
  762. X            |    |  |  |  +------------------ Point scale factor
  763. X            |    |  |  |  |
  764. X            |    |  |  |  |   +-------------- Sequence
  765. X            |    |  |  |  |   |
  766. X            |    |  |  |  |   |               Printable sequence title
  767. X            |    |  |  |  |   |                 |
  768. X            |    |  |  |  |   |                 |
  769. X            v    v  v  v  v   v                 v                    */
  770. X    /*  1*/    {S, 0, 0, 1, "\\171",        "psi"},
  771. X    /*  2*/    {S, 0, 0, 1, "\\161",        "theta"},
  772. X    /*  3*/    {S, 0, 0, 1, "\\156",        "nu"},
  773. X    /*  4*/    {S, 0, 0, 1, "\\155",        "mu"},
  774. X    /*  5*/    {S, 0, 0, 1, "\\154",        "lambda"},
  775. X    /*  6*/    {S, 0, 0, 1, "\\151",        "iota"},
  776. X    /*  7*/    {S, 0, 0, 1, "\\172",        "zeta"},
  777. X    /*  8*/    {S, 0, 0, 1, "\\163",        "sigma"},
  778. X    /*  9*/    {S, 0, 0, 1, "\\144",        "delta"},
  779. X    /* 10*/    {S, 0, 0, 1, "\\142",        "beta"},
  780. X    /* 11*/    {S, 0, 0, 1, "\\170",        "xi"},
  781. X    /* 12*/    {S, 0, 0, 1, "\\150",        "eta"},
  782. X    /* 13*/    {S, 0, 0, 1, "\\146",        "phi"},
  783. X    /* 14*/    {S, 0, 0, 1, "\\165",        "upsilon"},
  784. X    /* 15*/    {S, 0, 0, 1, "\\153",        "kappa"},
  785. X    /* 16*/    {S, 0, 0, 1, NOCODE,        "unassigned"},
  786. X    /* 17*/    {S, 0, 0, 1, "\\160",        "pi"},
  787. X    /* 18*/    {U, 0, 0, 1, "@",        "@"},
  788. X    /* 19*/    {S, 0, 0, 1, "\\257",        "down arrow"},
  789. X    /* 20*/    {S, 0, 0, 1, NOCODE,        "unassigned"},
  790. X    /* 21*/    {S, 0, 0, 1, "\\141",        "alpha"},
  791. X    /* 22*/    {S, 0, 0, 1, "\\174",        "or (was star)"},
  792. X    /* 23*/    {S, 0, 0, 1, "\\143",        "chi"},
  793. X    /* 24*/    {U, 0, 0, 1, "\\042",        "double quote"},
  794. X    /* 25*/    {S, 0, 0, 1, "\\145",        "epsilon"},
  795. X    /* 26*/    {S, 0, 0, 1, "\\075",        "equation equal"},
  796. X    /* 27*/    {S, 0, 0, 1, "\\157",        "omicron"},
  797. X    /* 28*/    {S, 0, 0, 1, "\\254",        "left arrow"},
  798. X    /* 29*/    {S, 0, 0, 1, "\\162",        "rho"},
  799. X    /* 30*/    {S, 0, 0, 1, "\\255",        "up arrow"},
  800. X    /* 31*/    {S, 0, 0, 1, "\\164",        "tau"},
  801. X    /* 32*/    {4, 0, 0, 1, "O",        "underline"},
  802. X    /* 33*/    {U, 0, 0, 1, "\\134",        "\\\\"},
  803. X    /* 34*/    {S, 0, 0, 1, "\\131",        "Psi"},
  804. X    /* 35*/    {D, 0, 0, 1, "BellSymbol",    "bell system sign"},
  805. X    /* 36*/    {S, 0, 0, 1, "\\245",        "infinity"},
  806. X    /* 37*/    {S, 0, 0, 1, "\\147",        "gamma"},
  807. X    /* 38*/    {S, 0, 0, 1, "\\312",        "improper superset"},
  808. X    /* 39*/    {S, 0, 0, 1, "\\265",        "proportional to"},
  809. X    /* 40*/    {S, 0, 0, 1, "\\336",        "right hand"},
  810. X    /* 41*/    {S, 0, 0, 1, "\\167",        "omega"},
  811. X    /* 42*/    {S, 0, 0, 1, NOCODE,        "unassigned"},
  812. X    /* 43*/    {S, 0, 0, 1, "\\321",        "gradient"},
  813. X    /* 44*/    {S, 0, 0, 1, NOCODE,        "unassigned"},
  814. X    /* 45*/    {S, 0, 0, 1, "\\106",        "Phi"},
  815. X    /* 46*/    {S, 0, 0, 1, "\\121",        "Theta"},
  816. X    /* 47*/    {S, 0, 0, 1, "\\127",        "Omega"},
  817. X    /* 48*/    {S, 0, 0, 1, "\\310",        "union"},
  818. X    /* 49*/    {4, 0, 0, 1, "M",        "root en"},
  819. X    /* 50*/    {S, 0, 0, 1, "\\123",        "terminal sigma (was root em)"},
  820. X    /* 51*/    {S, 0, 0, 1, "\\114",        "Lambda"},
  821. X    /* 52*/    {S, 0, 0, 1, "\\055",        "equation minus"},
  822. X    /* 53*/    {S, 0, 0, 1, "\\107",        "Gamma"},
  823. X    /* 54*/    {S, 0, 0, 1, "\\362",        "integral sign"},
  824. X    /* 55*/    {S, 0, 0, 1, "\\120",        "Pi"},
  825. X    /* 56*/    {S, 0, 0, 1, "\\314",        "subset of"},
  826. X    /* 57*/    {S, 0, 0, 1, "\\311",        "superset of"},
  827. X    /* 58*/    {U, 0, 0, 1, "\\176",        "approximates"},
  828. X    /* 59*/    {S, 0, 0, 1, "\\266",        "partial derivative"},
  829. X    /* 60*/    {S, 0, 0, 1, "\\104",        "Delta"},
  830. X    /* 61*/    {S, .35, 0, 1, "\\326",        "square root"},
  831. X    /* 62*/    {S, 0, 0, 1, "\\123",        "Sigma"},
  832. X    /* 63*/    {S, 0, 0, 1, "\\273",        "approx ="},
  833. X    /* 64*/    {S, 0, 0, 1, "\\076",        ">"},
  834. X    /* 65*/    {S, 0, 0, 1, "\\130",        "Xi"},
  835. X    /* 66*/    {S, 0, 0, 1, "\\074",        "<"},
  836. X    /* 67*/    {S, 0, 0, 1, "\\244",        "long slash (longer)"},
  837. X    /* 68*/    {S, 0, 0, 1, "\\307",        "intersect"},
  838. X    /* 69*/    {S, 0, 0, 1, "\\125",        "Upsilon"},
  839. X    /* 70*/    {S, 0, 0, 1, "\\330",        "logical not"},
  840. X    /* 71*/    {4, 0, 0, 1, "J",        "right ceiling"},
  841. X    /* 72*/    {4, 0, 0, 1, "B",        "left top brace"},
  842. X    /* 73*/    {4, 0, 0, 1, "A",        "bold vertical"},
  843. X    /* 74*/    {4, 0, 0, 1, "C",        "left ctr brace"},
  844. X    /* 75*/    {4, 0, 0, 1, "D",        "left bot brace"},
  845. X    /* 76*/    {4, 0, 0, 1, "E",        "right top brace"},
  846. X    /* 77*/    {4, 0, 0, 1, "F",        "right ctr brace"},
  847. X    /* 78*/    {4, 0, 0, 1, "G",        "right bot brace"},
  848. X    /* 79*/    {4, 0, 0, 1, "K",        "right floor"},
  849. X    /* 80*/    {4, 0, 0, 1, "I",        "left floor"},
  850. X    /* 81*/    {4, 0, 0, 1, "H",        "left ceiling"},
  851. X    /* 82*/    {S, 0, 0, 1, "\\264",        "multiply"},
  852. X    /* 83*/    {S, 0, 0, 1, "\\270",        "divide"},
  853. X    /* 84*/    {S, 0, 0, 1, "\\261",        "plus-minus"},
  854. X    /* 85*/    {S, 0, 0, 1, "\\243",        "<="},
  855. X    /* 86*/    {S, 0, 0, 1, "\\263",        ">="},
  856. X    /* 87*/    {S, 0, 0, 1, "\\272",        "identically equal"},
  857. X    /* 88*/    {S, 0, 0, 1, "\\271",        "not equal"},
  858. X    /* 89*/    {S, 0, 0, 1, "\\173",        "{"},
  859. X    /* 90*/    {S, 0, 0, 1, "\\175",        "}"},
  860. X    /* 91*/    {U, 0, 0, 1, "\\302",        "acute accent"},
  861. X    /* 92*/    {U, 0, 0, 1, "\\301",        "grave accent"},
  862. X    /* 93*/    {U, 0, 0, 1, "\\303",        "^"},
  863. X    /* 94*/    {U, 0, 0, 1, "\\043",        "#"},
  864. X    /* 95*/    {S, 0, 0, 1, "\\334",        "left hand"},
  865. X    /* 96*/    {S, 0, 0, 1, "\\316",        "member of"},
  866. X    /* 97*/    {U, 0, 0, 1, "\\304",        "~"},
  867. X    /* 98*/    {S, 0, 0, 1, "\\306",        "empty set"},
  868. X    /* 99*/    {S, 0, 0, 1, NOCODE,        "unassigned"},
  869. X    /*100*/    {U, 0, 0, 1, "\\263",        "dbl dagger"},
  870. X    /*101*/    {4, 0, 0, 1, "L",        "box rule (was parallel sign)"},
  871. X    /*102*/    {S, 0, 0, 1, "\\052",        "math * "},
  872. X    /*103*/    {S, 0, 0, 1, "\\315",        "improper subset"},
  873. X    /*104*/    {4, 0, 0, 1, "N",        "circle"},
  874. X    /*105*/    {S, 0, 0, 1, NOCODE,        "unassigned"},
  875. X    /*106*/    {S, 0, 0, 1, "\\053",        "equation plus"},
  876. X    /*107*/    {S, 0, 0, 1, "\\256",        "right arrow"},
  877. X    /*108*/    {U, 0, 0, 1, "\\247",        "section"}
  878. X};
  879. X
  880. XpsPage() {
  881. X    EMITPS("ShowPage\n");
  882. X    EMITPS("PageSave restore\n");
  883. X    pagePending = 1;
  884. X}
  885. X
  886. Xstatic
  887. XdoPageStart(e) {
  888. X    currentPage++;
  889. X    EMITPS("%%%%Page: ? %d\n", currentPage);
  890. X#ifdef    BIN
  891. X    switch(Bin) {
  892. X    case 'M':
  893. X        EMITPS("/manualfeed true def\n");
  894. X        break;
  895. X    default:
  896. X        fprintf(stderr, 
  897. X        "%s: bad bin selection %c - set to default\n", progname, 
  898. X        Bin);
  899. X        Bin = 'D';
  900. X    case 'D':
  901. X        EMITPS("/manualfeed false def\n");
  902. X        break;
  903. X    }
  904. X#endif
  905. X#ifdef    FORM
  906. X    EMITPS("/Form { %s } def\n", Overlay);
  907. X#endif
  908. X    EMITPS("/PageSave save def\n");
  909. X    pagePending = 0;
  910. X    EMITPS("StartPage\n");
  911. X}
  912. X
  913. Xstatic int lastFont = (-1), lastPoints = (-1);
  914. X
  915. XpsSetFont(font, points)
  916. Xint font, points; {
  917. X    if (lastPoints != points || font != lastFont) {
  918. X        psFts[font].flags |= USED;
  919. X#ifdef    FONTMACRO
  920. X        EMITPS("/%s %d SetFont\n", psFts[font].fontName, points);
  921. X#else
  922. X        EMITPS("/%s dup /curFont exch def findfont\n", 
  923. X        psFts[font].fontName);
  924. X        EMITPS("%d dup /curPoints exch def scalefont setfont\n", points);
  925. X#endif
  926. X        lastPoints = points;
  927. X        lastFont = font;
  928. X    }
  929. X}
  930. X
  931. XpsChar(x, y, font, points, troffChar) 
  932. Xint x, y, font, points, troffChar; {
  933. X    static double lasty = (-1);
  934. X    register double nx = TROFF2PSX(x), ny = TROFF2PSY(y);
  935. X    register struct troff2befont *rp;
  936. X    register char *sequence = "a";
  937. X    if (pagePending) {
  938. X        lasty = lastFont = lastPoints = (-1);
  939. X        doPageStart();
  940. X    }
  941. X
  942. X    charCount++;
  943. X
  944. X    DEBUGPRINTF("x,y=%d,%d; font=%d, points=%d, tc=%d\n",
  945. X        x, y, font, points, troffChar);
  946. X
  947. X    if (font == 3) {
  948. X        rp = &be->besymfont[troffChar];
  949. X    } else {
  950. X        rp = &be->bestdfont[troffChar];
  951. X    }
  952. X
  953. X    switch(rp->t2b_font) {
  954. X        /* Only fonts with "U" are subject to font translation */
  955. X        case U: 
  956. X        if (font == 3)
  957. X            font = 0;    /* Special chars are Courier */
  958. X        else {
  959. X            DEBUGPRINTF("psSetChar %d->%s (%s)\n", font, 
  960. X            t2psf[font]->troffName,
  961. X            t2psf[font]->fontName);
  962. X            font = t2psf[font] - psFts;
  963. X        }
  964. X        break;
  965. X        case S: 
  966. X        font = 3;
  967. X        break;
  968. X        case D:
  969. X        break;
  970. X        default:
  971. X        /* Typically used when the main fonts don't have the
  972. X           character desired.  Eg: right-hand is in the
  973. X           ZapfDingbats font */
  974. X        font = rp->t2b_font;
  975. X        break;
  976. X    }
  977. X
  978. X    sequence = rp->t2b_charseq;
  979. X
  980. X    if (!sequence) {
  981. X        fprintf(stderr, "No coding for %d\n", troffChar);
  982. X        return;
  983. X    }
  984. X
  985. X    /*    We're committed now */
  986. X
  987. X    points *= rp->t2b_scale;
  988. X    nx += points * rp->t2b_xc;
  989. X    ny += points * rp->t2b_yc;
  990. X    psSetFont(font, points);
  991. X    if (rp->t2b_font == D)
  992. X        EMITPS("%g %g %s\n", nx, ny, sequence);
  993. X    else {
  994. X        emitnum(nx);
  995. X        if (lasty != ny) {
  996. X        EMITPS(" ");
  997. X        emitnum(ny);
  998. X        EMITPS("(%s)Y\n", sequence);
  999. X        lasty = ny;
  1000. X        } else
  1001. X        EMITPS("(%s)X\n",sequence);
  1002. X    }
  1003. X}
  1004. X
  1005. Xemitnum(val)
  1006. Xdouble val; {
  1007. X    static char buffer[30];
  1008. X    register char *p;
  1009. X    sprintf(buffer, "%g", val);
  1010. X    p = strchr(buffer, '.');
  1011. X    if (p)
  1012. X    *(p+2) = '\0';
  1013. X    EMITPS(buffer);
  1014. X}
  1015. X
  1016. X
  1017. Xstatic
  1018. Xloadfontdefs(f)
  1019. XFILE *f; {
  1020. X    struct psFts *p = psFts;
  1021. X    extern char *malloc();
  1022. X    char rbuf[512], nbuf[512], psbuf[512];
  1023. X    while(fgets(rbuf, sizeof(rbuf), f)) {
  1024. X    switch(sscanf(rbuf, "%s%s", nbuf, psbuf)) {
  1025. X        default:
  1026. X        break;
  1027. X        case 2:
  1028. X        if (nbuf[0] == '#')
  1029. X            break;
  1030. X        if (p - psFts >= MAXFONT) {
  1031. X            fprintf(stderr, "Too many font definitions in %s\n",
  1032. X            PSFONTS);
  1033. X            exit(1);
  1034. X        }
  1035. X        p->troffName = malloc(strlen(nbuf) + 1);
  1036. X        strcpy(p->troffName, nbuf);
  1037. X        p->fontName = malloc(strlen(psbuf) + 1);
  1038. X        strcpy(p->fontName, psbuf);
  1039. X        p++;
  1040. X    }
  1041. X    }
  1042. X#ifdef    DEBUG
  1043. X    for (p = psFts; p->troffName; p++)
  1044. X    DEBUGPRINTF("%s -> %s\n", p->troffName, p->fontName);
  1045. X#endif
  1046. X}
  1047. X
  1048. Xextern char nodename[];
  1049. X
  1050. XpsProlog() {
  1051. X    extern char *getlogin(), *ctime();
  1052. X    extern char *strchr();
  1053. X    char buffer[512];
  1054. X    char *lognm;
  1055. X    FILE *library;
  1056. X    int c;
  1057. X    long curtime;
  1058. X
  1059. X    currentPage = 0;
  1060. X    pagePending = 1;
  1061. X
  1062. X    for (c = 0; c < 8; c++)
  1063. X    t2psf[c] = &psFts[c];
  1064. X    if ((library = fopen(PSFONTS, "r")) == NULL) {
  1065. X    sprintf(buffer, "%s/%s", LIBDIR, PSFONTS);
  1066. X    if ((library = fopen(buffer, "r")) == NULL) {
  1067. X        fprintf(stderr, "Cannot open PostScript font definitions %s\n",
  1068. X        buffer);
  1069. X        exit(1);
  1070. X    }
  1071. X    }
  1072. X
  1073. X    loadfontdefs(library);
  1074. X    fclose(library);
  1075. X
  1076. X    if ((library = fopen(PSLIB, "r")) == NULL) {
  1077. X    sprintf(buffer, "%s/%s", LIBDIR, PSLIB);
  1078. X    if ((library = fopen(buffer, "r")) == NULL) {
  1079. X        fprintf(stderr, "Cannot open %s\n", buffer);
  1080. X        exit(1);
  1081. X    }
  1082. X    }
  1083. X
  1084. X    time(&curtime);
  1085. X    strcpy(buffer, ctime(&curtime));
  1086. X    *strchr(buffer, '\n') = '\0';
  1087. X    getnodename();
  1088. X
  1089. X    lognm = getlogin();
  1090. X    if (!lognm || !*lognm)
  1091. X    lognm = "unknown";
  1092. X
  1093. X    EMITPS("%%!PS-Adobe-1.0\n");
  1094. X    EMITPS("%%%%Title: (stdin)\n");
  1095. X    EMITPS("%%%%Creator: %s %s %s\n", lognm, progname, T2VERSION);
  1096. X    EMITPS("%%%%CreationDate: %s\n", buffer);
  1097. X    EMITPS("%%%%For: %s\n", lognm);
  1098. X    EMITPS("%%%%Pages: (atend)\n");
  1099. X    EMITPS("%%%%DocumentFonts: (atend)\n");
  1100. X    EMITPS("%%%%EndComments\n");
  1101. X    EMITPS("(%s@%s %s %s %s\n) print\n", lognm, nodename, buffer, 
  1102. X    progname, T2VERSION);
  1103. X    psXlate(library);
  1104. X    EMITPS("/GlobalSave save def\n");
  1105. X    EMITPS("%%%%EndProlog\n");
  1106. X    fclose(library);
  1107. X}
  1108. X
  1109. XpsEpilog() {
  1110. X    int i;
  1111. X#ifdef    METRICS
  1112. X    int curpos = 720;        /* ten inches from bottom of page */
  1113. X#define    XD    36
  1114. X#define    CH    16
  1115. X    if (metrics) {
  1116. X    psBin("");
  1117. X    psOverlay("");
  1118. X    doPageStart();
  1119. X    lastFont = -1;    /* force the font change nomatter what */
  1120. X    psSetFont(0, 16);
  1121. X    EMITPS("%d %d(%s Execution Summary:)Y\n", progname, XD, curpos);
  1122. X    curpos -= CH;
  1123. X    EMITPS("%d %d(Font cache hits: )Y Hits show\n",
  1124. X        XD + 18, curpos);
  1125. X    curpos -= CH;
  1126. X    EMITPS("%d %d(Font cache misses: )Y Misses show\n",
  1127. X        XD + 18, curpos);
  1128. X    curpos -= CH;
  1129. X    EMITPS("%d %d(Character Count: %d)Y\n",
  1130. X        charCount, XD + 18, curpos);
  1131. X    psPage();
  1132. X    }
  1133. X#endif
  1134. X    EMITPS("%%%%Trailer\n");
  1135. X    EMITPS("GlobalSave restore\n");
  1136. X    EMITPS("%%%%DocumentFonts:");
  1137. X    for (i = 0; i < MAXFONT; i++)
  1138. X    if (psFts[i].flags&USED)
  1139. X        EMITPS(" %s", psFts[i].fontName);
  1140. X    EMITPS("\n");
  1141. X    EMITPS("%%%%Pages: %d\n", currentPage);
  1142. X    putchar('\004');
  1143. X}
  1144. X
  1145. XpsFontSel(from, to)
  1146. Xchar from, *to; {
  1147. X#ifdef    DEBUG
  1148. X    register int i;
  1149. X    register struct psFts *p;
  1150. X#endif
  1151. X    DEBUGPRINTF("psFontSel: %c -> %s\n", from, to);
  1152. X    if (from < '1' || from > '8') {
  1153. X    fprintf(stderr, "Bad arguments to psFontSel: %c %s\n", from, to);
  1154. X    return;
  1155. X    }
  1156. X
  1157. X    for (p = psFts; p->troffName; p++)
  1158. X    if (strcmp(p->troffName, to) == 0) {
  1159. X        t2psf[from - '1'] = p;
  1160. X        break;
  1161. X    }
  1162. X    if (!p->troffName) {
  1163. X    fprintf(stderr, "Could not translate font %c (%s)\n", from, to);
  1164. X    }
  1165. X#ifdef    DEBUG
  1166. X    for (i = 0; i < 8; i++)
  1167. X    DEBUGPRINTF("Font %d->%s\n", i+1, t2psf[i]->fontName);
  1168. X#endif
  1169. X}
  1170. X
  1171. X/*struct troff2befont *
  1172. XpsGetFontTables(which)
  1173. Xint which; {
  1174. X    return(which? symbolFont: standardFont);
  1175. X}*/
  1176. X
  1177. XpsXlate(library)
  1178. XFILE *library; {
  1179. X    char buf[512];
  1180. X    while (fgets(buf, sizeof(buf), library))
  1181. X    if (0 == strncmp(buf, "%%%", 3))
  1182. X        interp(&buf[3], psXlate, ".ps");
  1183. X    else
  1184. X        fputs(buf, stdout);
  1185. X}
  1186. X
  1187. XpsOverlay(overlay)
  1188. Xchar *overlay; {
  1189. X#ifdef    FORM
  1190. X    strcpy(Overlay, overlay);
  1191. X    EMITPS("%%%%%%Form set: %s\n", Overlay);
  1192. X#endif
  1193. X}
  1194. X
  1195. XpsBin(bin)
  1196. Xchar *bin; {
  1197. X#ifdef    BIN
  1198. X    Bin = *bin;
  1199. X#endif
  1200. X}
  1201. X
  1202. X#endif /* PS */
  1203. END_OF_FILE
  1204. if test 19066 -ne `wc -c <'ps.c'`; then
  1205.     echo shar: \"'ps.c'\" unpacked with wrong size!
  1206. fi
  1207. # end of 'ps.c'
  1208. fi
  1209. echo shar: End of archive 5 \(of 6\).
  1210. cp /dev/null ark5isdone
  1211. MISSING=""
  1212. for I in 1 2 3 4 5 6 ; do
  1213.     if test ! -f ark${I}isdone ; then
  1214.     MISSING="${MISSING} ${I}"
  1215.     fi
  1216. done
  1217. if test "${MISSING}" = "" ; then
  1218.     echo You have unpacked all 6 archives.
  1219.     echo "Read README to install psroff"
  1220.     rm -f ark[1-9]isdone
  1221. else
  1222.     echo You still need to unpack the following archives:
  1223.     echo "        " ${MISSING}
  1224. fi
  1225. ##  End of shell archive.
  1226. exit 0
  1227.  
  1228.